package com.fighYo.vod.controller;

import com.fighYo.commonutils.R;
import com.fighYo.vod.service.VodService;
import com.fighYo.vod.util.ConstantPropertiesUtil;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@CrossOrigin
@RestController
@RequestMapping("/vod")
public class VodController {

    @Autowired
    private VodService vodService;

    @PostMapping("upload")
    public R uploadVideo(@RequestParam("file") MultipartFile file) {
        String id = vodService.uploadVideo(file);
        return R.ok().data("videoId", id);
    }

    @DeleteMapping("{videoId}")
    public R removeVideo(@ApiParam(name = "videoId", value = "云端视频id", required = true)
                         @PathVariable String videoId){
        vodService.removeVideo(videoId);
        return R.ok().message("视频删除成功");
    }


}
